﻿@model PrjAssessModels.BaseModels.Project

@section scripts{
    <script type="text/javascript">
        $(document).ready(function ()
        {
            var viewModelJs = '@Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(this.Model))';
            var viewModel = ko.mapping.fromJSON(viewModelJs);
            viewModel.PrjExtent.WorkRatio = ko.computed(function ()
            {
                try
                {
                    return parseFloat(this.SupportNo()) + parseFloat(this.EnviComplicate()) + parseFloat(this.OperateMethod());
                }
                catch (e)
                {
                    return 0;
                }
            }, viewModel.PrjExtent);

            viewModel.PrjExtent.PrjRatio = ko.computed(function ()
            {
                try
                {
                    return parseFloat(this.RegionRatio()) * parseFloat(this.ComplicateRatio()) * parseFloat(this.SurveyTypeRatio()) * parseFloat(this.TeamRatio()) * parseFloat(this.ScaleRatio());
                }
                catch (e)
                {
                    return 0;
                }
            }, viewModel.PrjExtent);
            ko.applyBindings(viewModel);
            $("#FormTab").ejTab({ allowKeyboardNavigation: false });
            $('#myForm').submit(function (event)
            {

                event.preventDefault();
                var jsonData = ko.toJSON(viewModel);
                var url = '@Url.Action("SaveBasicInfo","DoAssess")';
                    $.post(url, { 'prjJson': jsonData },
                        function (data)
                        {
                            if (data = 1)
                            {
                                document.location.href = '@Url.Action("Index","DoAssess")';
                            }
                            else
                            {
                                alert('Err!');

                            }
                        });
                //not submit now!
                return false;
             });
        });
        

    </script>
}
<br />


<div class="container">
    @using (Html.BeginForm("SaveBasicInfo", "DoAssess", FormMethod.Post, new { id = "myForm", enctype = "multipart/form-data", @class = "form-horizontal" }))
    {
        <input type="submit" id="submit" class="btn  btn-danger" value="保存更改" />
        <br /><br />
        <div id="FormTab">
            <ul>
                <li><a href="#BasicForm">基本信息</a></li>
                <li><a href="#WorkParaForm">工作量系数</a></li>
                <li><a href="#ParaForm">综合系数</a></li>
                <li><a href="#PurchaseForm">采购系数</a></li>
            </ul>
            <div id="BasicForm">
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjName, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjName, new { @class = "form-control", data_bind = "value: PrjName", placeholder = "工程名称", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjId, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjId, new { data_bind = "value: PrjId", @class = "form-control", placeholder = "工程编号", required = "",@readonly = "readonly"  })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Contract, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.Contract, new { data_bind = "value: Contract", @class = "form-control", placeholder = "合同额", type = "number", required = "", step = "any" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Address, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.Address, new { data_bind = "value: Address", @class = "form-control", placeholder = "地址", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Manager, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.Manager, new { data_bind = "value: Manager", @class = "form-control", placeholder = "项目经理", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Leader, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.Leader, new { data_bind = "value: Leader", @class = "form-control", placeholder = "班组长", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.Manufacture, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.Manufacture, new { data_bind = "value: Manufacture", @class = "form-control", placeholder = "采购厂商", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.MonitorType, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.MonitorType, new { data_bind = "value: MonitorType", @class = "form-control", placeholder = "监测类型", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.SurveyNo, new { @class = "col-lg-2 control-label text-danger" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.SurveyNo, new { data_bind = "value: SurveyNo", @class = "form-control", placeholder = "监测次数", type = "number", step = "any", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.ConstructionPeriod, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.ConstructionPeriod, new { data_bind = "value: ConstructionPeriod", @class = "form-control", placeholder = "工期", type = "number", step = "any", required = "" })
                    </div>
                </div>
            </div>
            <div id="WorkParaForm" data-bind="with: PrjExtent">
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjExtent.WorkRatio, new { @class = "col-lg-2 control-label text-info" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjExtent.WorkRatio, new { @class = "form-control", data_bind = "value: WorkRatio", placeholder = "基坑工作量系数", type = "number", required = "", step = "any", @readonly = "readonly" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjExtent.SupportNo, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjExtent.SupportNo, new { @class = "form-control", data_bind = "value: SupportNo", placeholder = "支撑层数", type = "number", step = "any", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjExtent.EnviComplicate, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjExtent.EnviComplicate, new { @class = "form-control", data_bind = "value: EnviComplicate", placeholder = "环境复杂度", type = "number", step = "any", required = "" })
                    </div>
                </div>
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjExtent.OperateMethod, new { @class = "col-lg-2 control-label" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjExtent.OperateMethod, new { @class = "form-control", data_bind = "value: OperateMethod", placeholder = "施作方式", type = "number", step = "any", required = "" })
                    </div>
                </div>
            </div>
            <div id="ParaForm" data-bind="with: PrjExtent">
                  <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.PrjRatio, new { @class = "col-lg-2 control-label text-info" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.PrjRatio, new { @class = "form-control", data_bind = "value: PrjRatio", placeholder = "工程综合系数", type = "number", required = "", step = "any", @readonly = "readonly" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.RegionRatio, new { @class = "col-lg-2 control-label" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.RegionRatio, new { @class = "form-control", data_bind = "value: RegionRatio", placeholder = "地域系数", type = "number", step = "any", required = "" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.ComplicateRatio, new { @class = "col-lg-2 control-label" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.ComplicateRatio, new { @class = "form-control", data_bind = "value: ComplicateRatio", placeholder = "复杂系数", type = "number", step = "any", required = "" })
                        </div>
                    </div>


                    <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.SurveyTypeRatio, new { @class = "col-lg-2 control-label" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.SurveyTypeRatio, new { @class = "form-control", data_bind = "value: SurveyTypeRatio", placeholder = "监测类型系数", type = "number", step = "any", required = "" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.TeamRatio, new { @class = "col-lg-2 control-label" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.TeamRatio, new { @class = "form-control", data_bind = "value: TeamRatio", placeholder = "班组折减率", type = "number", step = "any", required = "" })
                        </div>
                    </div>

                    <div class="form-group">
                        @Html.LabelFor(m => m.PrjExtent.ScaleRatio, new { @class = "col-lg-2 control-label" })
                        <div class="col-lg-10">
                            @Html.TextBoxFor(m => m.PrjExtent.ScaleRatio, new { @class = "form-control", data_bind = "value: ScaleRatio", placeholder = "规模效应折减", type = "number", step = "any", required = "" })
                        </div>
                    </div>
            </div>
            <div id="PurchaseForm" data-bind="with: PrjExtent">
                <div class="form-group">
                    @Html.LabelFor(m => m.PrjExtent.MaterialPurchaseRatio, new { @class = "col-lg-2 control-label text-info" })
                    <div class="col-lg-10">
                        @Html.TextBoxFor(m => m.PrjExtent.MaterialPurchaseRatio, new {data_bind = "value: MaterialPurchaseRatio", @class = "form-control", placeholder = "材料采购系数", type = "number", step = "any", required = "" })
                    </div>
                </div>
            </div>
        </div>
        <br />
        }
</div>
